package com.test;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.concurrent.TimeUnit;

import com.alibaba.dubbo.demo.Student;

import feign.Feign;
import feign.Request;
import feign.Target.EmptyTarget;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder2;
import feign.okhttp.OkHttpClient;

public class GetDemo3 {

	public static void main(String[] args) throws URISyntaxException {
		FeignService feignService = Feign.builder()
				.client(new OkHttpClient())
				.options(new Request.Options(200, TimeUnit.MILLISECONDS, 500, TimeUnit.MILLISECONDS, true))
				.encoder(new JacksonEncoder2())
				.decoder(new JacksonDecoder())
				.requestInterceptor(new MyRequestInterceptor())
				.target(EmptyTarget.create(FeignService.class));
		// 接口在spring-webflux的com.demo.webflux.feigncore里
		List<Student> contributors = feignService.contributors0("OpenFeign", 10, new URI("http://localhost:8085"));
		for (Student contributor : contributors) {
			System.out.println(contributor.getName() + " ("+ contributor.getAge() + ")");
		}
	}

}
